<?php
/**
 * Funkjca do obsługi danych na liscie performara
 * @author KOPI
 */
function smarty_function_listData($param, &$smarty) {
	 $listData = unserialize($param["obj"]->getListData());

	 //sprawdzamy czy jest cooki na tego performera
	 //
	
	 if(Request::GetCookie($param["obj"]->getId()))
	 {
		 $param["obj"]->setOnline(0);
	 }


	$stream = '';
	$video = '';
	$class = '';
	$rel = '';
	 
	if($param["obj"]->getStatus() == 1){
	 	//tylko jesli user zalogowany lub free chat
		if($param["obj"]->getFreechat() == 1 || get_class($param['user']) == 'User' || get_class($param['user']) == 'Performer' || get_class($param['user']) == 'Agency'){
			$rel='rel="1"';
			if ($param["obj"]->getStreamName() != ''){
				$stream = 'rels="' . $param["obj"]->getStreamName() . '"';
				$class='listVideo';
			}	 
		}
	}
	 
	if ( isset($listData['video'])){ 
		$video ='relv="' . Config::Get('URL_STATIC_CONTENT') .  $listData['video'] . '"';	 
		$class='listVideo';
	}

	$url = Router::GenerateUrl('showFreeChat', array('idPerformer' => $param["obj"]->getId(), 'loginPerformer' => $param["obj"]->getLoginUrl(), 'idCategory' => $param["obj"]->getIdCategory(), 'titleCategory' => $param["obj"]->category->getNameUrl()));
	if(isset($param['snapshot']))$url = Router::GenerateUrl('userSnapshotGalleryFilter',array('id' => $param['obj']->getId()));
	 

	 $return ='
		<div class="ItemBoxBackgroundImage" style="background-image:url(' . Config::Get('URL_STATIC_CONTENT') . '/'. $listData['image'] . ')">

			<img src="' . URL_STATIC_CONTENT . '/image/Strona/transparent.gif" ' . $rel . ' id="player' . $param["obj"]->getId() . '" class="ItemBoxHref ' . $class . '"   onClick="location.href=\'' . $url . '\'"/>
			<div ' . $stream . ' '. $video .' id="player' . $param["obj"]->getId() . 'video" class="ItemBoxPlayer ' . $class . '" >
			</div>
		</div>
		';

	 return $return;
}
